package mainWindow;
import java.util.ArrayList;
import java.util.List;

import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.jface.viewers.ComboViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.widgets.Composite;

import Components.Brand;
import Components.chooseUser;
import Components.user;
import DataDefinition.Config;
import DataDefinition.Users;

import org.eclipse.swt.events.ShellAdapter;
import org.eclipse.swt.events.ShellEvent;
import org.eclipse.swt.widgets.Table;
import org.eclipse.jface.viewers.TableViewer;


public class main {

	
	protected Shell shell;
	private Composite composit = null;
	private Config configuration;
	private static List<Users> uzivatelia;
	static public MenuItem mntmWho;
	
	public static List<Users> getUzivatelov(){
		return uzivatelia;
	}
	
	static{
		uzivatelia = new ArrayList<Users>();
	}
	
	/**
	 * Launch the application.
	 * @param args
	 */
	public static void main(String[] args) {
		try {
			main window = new main();
			window.open();
		} catch (Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Open the window.
	 */
	public void open() {
		
		
		Display display = Display.getDefault();
		createContents();
		shell.open();
		shell.layout();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
	}

	/**
	 * Create contents of the window.
	 */
	protected void createContents() {
		shell = new Shell();
		shell.addShellListener(new ShellAdapter() {
			@Override
			public void shellActivated(ShellEvent e) {
			}
		});
		shell.setSize(509, 353);
		shell.setText("SWT Application");
		
		Menu menu = new Menu(shell, SWT.BAR);
		shell.setMenuBar(menu);
		
		MenuItem options = new MenuItem(menu, SWT.CASCADE);
		options.setText("Options");
		
		Menu menu_1 = new Menu(options);
		options.setMenu(menu_1);
		
		MenuItem mntmMeasurements = new MenuItem(menu_1, SWT.NONE);
		mntmMeasurements.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (composit!=null)
					composit.dispose();
				composit = new Brand(shell,SWT.None);
				composit.setBounds(0,0,shell.getBounds().height,shell.getBounds().width);
			}
		});
		mntmMeasurements.setText("Measurements");
		
		MenuItem mntmNewItem_1 = new MenuItem(menu_1, SWT.NONE);
		mntmNewItem_1.setText("New Item");
		
		MenuItem mntmUsers = new MenuItem(menu, SWT.CASCADE);
		mntmUsers.setText("Users");
		
		Menu menu_2 = new Menu(mntmUsers);
		mntmUsers.setMenu(menu_2);
		
		MenuItem mntmAdd = new MenuItem(menu_2, SWT.NONE);
		mntmAdd.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (composit!=null)
					composit.dispose();
				composit = new user(shell,SWT.None);
				composit.setBounds(0,0,shell.getBounds().height,shell.getBounds().width);
			}
		});
		mntmAdd.setText("Add");
		
		MenuItem mntmChooseUser = new MenuItem(menu_2, SWT.NONE);
		mntmChooseUser.addSelectionListener(new SelectionAdapter() {
			@Override
			public void widgetSelected(SelectionEvent e) {
				if (composit!=null)
					composit.dispose();
				composit = new chooseUser(shell,SWT.None);
				composit.setBounds(0,0,shell.getBounds().height,shell.getBounds().width);
			}
		});
		mntmChooseUser.setText("Choose User");
		
		MenuItem mntmAdminAcces = new MenuItem(menu, SWT.CASCADE);
		mntmAdminAcces.setText("Admin acces");
		
		Menu menu_3 = new Menu(mntmAdminAcces);
		mntmAdminAcces.setMenu(menu_3);
		
		mntmWho = new MenuItem(menu, SWT.NONE);
		mntmWho.setText("Who");
		
	
		

	}
}
